﻿<%@ Page Title="Offset" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Offset.aspx.cs" Inherits="ColorApplication.color.Offset" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="adminContent">
        <h2>Offset
        </h2>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div id="modalPage" runat="server" class="modalPage">
                    <div class="modalBackground">
                    </div>
                    <div class="modalContainer">
                        <div class="modal">
                            <table>
                                <tr>
                                    <td align="center">
                                        <div style="background-color: White; border-radius: 5px; color: black; height: 47px;
                                            padding-top: 5px;">
                                            Please Wait...
                                        <br />
                                            <img src="../Images/preloader.gif" />
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="ErrorLabel" runat="server" CssClass="failureNotification"></asp:Label>
                <asp:Label ID="SuccesLabel" runat="server" CssClass="successNotification"></asp:Label>
                <asp:DetailsView ID="OffsetDetailsView" runat="server" Height="50px" Width="100%"
                    AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="OffsetDetailsviewSqlDataSource"
                    DefaultMode="Insert" OnItemInserted="OffsetDetailsView_ItemInserted" OnItemUpdated="OffsetDetailsView_ItemUpdated"
                    OnItemInserting="OffsetDetailsView_ItemInserting" OnItemUpdating="OffsetDetailsView_ItemUpdating">
                    <Fields>
                        <asp:TemplateField HeaderText="Attribute1" SortExpression="Attribute1">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditAttribute1DropDownList" runat="server" DataSourceID="AttributeSqlDataSource"
                                    DataTextField="Description" DataValueField="Id" SelectedValue='<%# Bind("Attribute1") %>'>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertAttribute1DropDownList" runat="server" DataSourceID="AttributeSqlDataSource"
                                    DataTextField="Description" DataValueField="Id" SelectedValue='<%# Bind("Attribute1") %>'>
                                </asp:DropDownList>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("Attribute1") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Attribute2" SortExpression="Attribute2">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditAttribute2DropDownList" runat="server" DataSourceID="AttributeSqlDataSource"
                                    DataTextField="Description" DataValueField="Id" SelectedValue='<%# Bind("Attribute2") %>'>
                                </asp:DropDownList>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertAttribute2DropDownList" runat="server" DataSourceID="AttributeSqlDataSource"
                                    DataTextField="Description" DataValueField="Id" SelectedValue='<%# Bind("Attribute2") %>'>
                                </asp:DropDownList>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("Attribute2") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField ShowEditButton="true" ShowInsertButton="true" />
                    </Fields>
                </asp:DetailsView>
                <asp:SqlDataSource ID="AttributeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    SelectCommand="GetAttributesSelect" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="false">
                    <SelectParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="OffsetDetailsviewSqlDataSource" runat="server" CancelSelectOnNullParameter="False"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" InsertCommand="InsertOffset"
                    InsertCommandType="StoredProcedure" SelectCommand="GetOffset" SelectCommandType="StoredProcedure"
                    UpdateCommand="UpdateOffset" UpdateCommandType="StoredProcedure">
                    <InsertParameters>
                        <asp:Parameter Name="Attribute1" Type="Int32" />
                        <asp:Parameter Name="Attribute2" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="OffsetGridView" Name="Id" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="Attribute1" Type="Int32" />
                        <asp:Parameter Name="Attribute2" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <br />
                <br />
                <table>
                    <tr>
                        <td>Search By Attributes :
                        </td>
                        <td>
                            <asp:TextBox ID="SearchDescriptionTextBox" AutoPostBack="true" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <br />
                <asp:GridView ID="OffsetGridView" runat="server" AllowPaging="True" AllowSorting="True"
                    AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="OffsetGridViewSqlDataSource"
                    OnSelectedIndexChanged="OffsetGridView_SelectedIndexChanged" OnRowDeleting="OffsetGridView_RowDeleting">
                    <Columns>
                        <asp:BoundField DataField="Attribute1" HeaderText="Attribute1" ReadOnly="True" SortExpression="Attribute1" />
                        <asp:BoundField DataField="Attribute2" HeaderText="Attribute2" ReadOnly="True" SortExpression="Attribute2" />
                        <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:LinkButton ID="DeleteLinkButton" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="Delete" OnClientClick="return getDeleteMessage()"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="OffsetGridViewSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    DeleteCommand="DeleteOffset" DeleteCommandType="StoredProcedure" SelectCommand="GetOffsetWithAttributeName"
                    CancelSelectOnNullParameter="false" SelectCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="SearchDescriptionTextBox" Name="Description" PropertyName="Text"
                            Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
